import Cookies from 'js-cookie'
const TokenKey = 'lz_token'
const StorageKey = 'lz-sass-'

// token 操作
export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

// companyId 操作
export function getCompanyId() {
  return Cookies.get(`${StorageKey}CompanyId`)
}

export function setCompanyId(value) {
  return Cookies.set(`${StorageKey}CompanyId`, value)
}

export function removeCompanyId() {
  return Cookies.remove(`${StorageKey}CompanyId`)
}

// cookie 操作
export function getCookie(key) {
  return Cookies.get(key)
}

export function setCookie(key, value) {
  return Cookies.set(key, value)
}

export function removeCookie(key) {
  return Cookies.remove(key)
}

// localStorage 操作
export function getItem(key) {
  return localStorage.getItem(`${StorageKey}${key}`)
}

export function setItem(key, val) {
  return localStorage.setItem(`${StorageKey}${key}`, val)
}

export function removeItem(key) {
  return localStorage.removeItem(`${StorageKey}${key}`)
}

export function clearIteme() {
  return localStorage.clear()
}

// 是否登录
export function isLogin() {
  return !!getToken()
}
